<%@ include file="../../base/include.jsp"%>
<%@ include file="../../preview/preview.jsp"%>

<c:if test="${not empty feedbackList}">
	<table class="table table-striped table-condensed">
		<thead>
			<tr>
				<th>Date</th>
				<th>Text</th>
				<th>Page</th>
				<th>Author</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="feedback" items="${feedbackList.list}">
				<tr>
					<td><fmt:formatDate value="${feedback.dateSend }" pattern="dd-MM-yyyy HH:mm" type="date"/></td>
					<td>${feedback.intro } 
						<c:if test="${feedback.more }">
							<a onclick="viewFeedback('${feedback.id}');" href="#">more</a>
						</c:if>
					</td>
					<td><a href="<c:url value="${feedback.page}"/>">${feedback.page}</a></td>
					<td>${feedback.author.name}</td>
					<td>
						<span class="badge badge-info pointerCursor"
							onclick="showMessage(${feedback.id}, 'deleteFB');"
							title="Delete feedback">
							<i class="icon-remove icon-white"></i>
						</span>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	
	<div id="myModal" class="modal fade in" style="display: none;">
		<div class="modal-header" style="border-bottom: 0px;">
			<a href="#" class="close" data-dismiss="modal">&times;</a>
			<h3>Confirm</h3>
		</div>
		<div class="modal-body">
			<div>
				<p>
					<strong id="message"></strong>
				</p>
			</div>
		</div>
		<div class="modal-footer">
			<div class="alert-actions">
				<a id="btnNo" class="btn" href="#" data-dismiss="modal">No</a> 
				<a id="btnYes" class="btn btn-primary" href="#">Yes</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		
	
	function showMessage(id, cmnd) {
		if (cmnd == "deleteFB") {
			document.getElementById('message').innerHTML = "Do you want to delete this feedback?";
			document.getElementById('btnYes').setAttribute('href', '<c:url value="/admin/feedback/remove/' + id +'"/>');
		} 

		$('#myModal').modal({
			backdrop: true,	
			keyboard: true,
			show: true
		});
	};
	
	function viewFeedback(id){
		var modalElem = $('#preview-modal');
		modalElem.find('.modal-body').load(applicationName + '/admin/feedback/preview/' + id, function(response, status, xhr){
			showModal(modalElem);
		});
	}
	$('#menuFeedback').addClass('active');
	setActiveMainMenuElem('administration');
</script>

</c:if>